﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Worker
{
    public partial class CaptchaForm : Form
    {
        public CaptchaForm()
        {
            InitializeComponent();
        }

        public string CaptchaAnswer
        {
            get { return tbCaptcha.Text; }
        }

        public Image CaptchaImage
        {
            set
            {
                pbCaptcha.Image = value;
                if (value == null)
                    return;
                pbCaptcha.Width = value.Width;
                pbCaptcha.Height = value.Height;
                if (pbCaptcha.Width > 209)
                    Width = pbCaptcha.Width + 33;
                if (pbCaptcha.Height > 20)
                {
                    Height = pbCaptcha.Height + 130;
                    btOk.Top = pbCaptcha.Bottom + 4;
                    tbCaptcha.Top = pbCaptcha.Bottom + 4;
                }
            }
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void CaptchaForm_Shown(object sender, EventArgs e)
        {
            tbCaptcha.Focus();
        }
    }
}
